package com.gzy.rpsm_property.controller;


import com.gzy.rpsm_property.pojo.ResponsePojo;
import com.gzy.rpsm_property.pojo.Room;
import com.gzy.rpsm_property.service.RoomService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@Api(tags = "房间相关 API")
@RestController
@RequestMapping("/room")
public class RoomController {
    @Autowired
    RoomService roomService;
    @GetMapping("/roomsOfFloor/{floor_id}")
    @ApiOperation(value = "根据楼层 id 查询房间信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name="floor_id",type = "Integer",required = true)
    })
    public ResponsePojo<List<Room>>
    roomsOfFloor(@PathVariable("floor_id")Integer id){
        List<Room> list = roomService.roomsOfFloor(id);
        if(list.size() > 0){
            return ResponsePojo.success(list);
        }
        return ResponsePojo.fail(list,"floorId 查询不到对应房间 ");
    }
}
